﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using RichTestEditorTest;
using System.IO;
using RichTestEditorTest.Properties;
using System.Globalization;
using System.Threading;

namespace Blog_Writer_App
{
    /// <summary>
    /// Interaction logic for Window2.xaml
    /// </summary>
    public partial class Window2 : Window
    {
        public Window2()
        {
            CultureInfo cult = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentCulture = cult;
            Thread.CurrentThread.CurrentUICulture = cult;

            InitializeComponent();

            MemoryStream iconStream = new MemoryStream();
            Res.Word_32x32.Save(iconStream, System.Drawing.Imaging.ImageFormat.Png);
            iconStream.Seek(0, SeekOrigin.Begin);
            BitmapFrame newIcon = BitmapFrame.Create(iconStream);
            this.Icon = newIcon;

            //this.Icon = (ImageSource)Res.Word_32x32;

            Dictionary<string, string> dictInsertTextItems = new Dictionary<string, string>();

            for (int i = 0; i < 10; i++)
            {
                dictInsertTextItems.Add("_itemKey_"+i,"Item Label "+i);
            }
            this.m_richTextEditor.InsertCustomTextItems = dictInsertTextItems;
        }

        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TabItem selectedItem = this.m_tabControl.SelectedItem as TabItem;

            switch (selectedItem.Name)
            {
                case "editor":
                    break;

                case "browser":
                    this.m_webBrowser.NavigateToString(this.m_richTextEditor.HTML);
                    break;

                case "code":
                    this.m_htmlCode.Text = this.m_richTextEditor.HTML;
                    break;

                default:
                    break;
            }
        }
    }
}
